home *** CD-ROM | disk | FTP | other *** search
- /*
- pen play.c
-
- This application creates various paths. We will then apply different pen styles to each path. We play with
- the pen size and location of the pen (i.e. on, inset, and outside of the geometry).
-
- NOTES:
- • This file requires the following files to run correctly:
- "graphics shell.c", "ColorLibrary.c", "GraphicsDebugLibrary.c",
- "ShapeLibrary.c", "TransformLibrary.c".
-
- • This file prints the "best" in landscape mode.
-
- Change History:
-
- 4/96 bob Updated #includes to support changed GX Library names.
- Updated the note regarding the files needed to run.
- Updated the copyright date.
-
- ©1992 - 1996 Apple Computer, Inc.
- All rights reserved.
- */
-
- #include <events.h>
- #include <windows.h>
-
- #include "FontLibrary.h"
- #include "GraphicsLibraries.h"
- #include <GXEnvironment.h>
- #include "graphics shell.h"
-
- //
- // Set up the title and size of the window
- //
- Str255 gWindowTitle = "\p Pen Play...";
- Rect gWindowQDRect = {40, 10, 445, 575};
-
- //
- // gGraphicsHeapSize sets the size of the graphics heap created by calling the GXNewGraphicsClient routine
- // in main () within graphics shell.c. You can determine the amount of graphics heap required by using GraphicsBug.
- // With gGraphicsHeapSize set to 135k, I had 15 free blocks left in the graphics heap. Sounds good to me.
- //
- long gGraphicsHeapSize = 135;
-
- gxShape gThePage;
-
-
- //
- // We use "gShapesInPicture" in the DoDraw function. If we have added shapes to the picture, we draw it. Otherwise, we
- // wait for the user to click in the window, thereby adding a gxShape to the picture.
- //
- Boolean gShapesInPicture;
-
-
-
- /*------ DoInitialization ---------------------------------------------------------------------------------*/
-
- void DoInitialization(gWindow)
- WindowPtr gWindow;
- {
- gxShape thePath;
- long tripleDumpGeometricData[] = { 1, // number of contours
- 6, // number of points
- 0xff000000,
- 0, 0, // the points
- ff(75), 0,
- ff(5), ff(50),
- ff(75), ff(100),
- 0, ff(100),
- ff(75), ff(50)};
-
- long ovalWabbleGeometricData[] = { 1, // number of contours
- 6, // number of points
- 0xff000000,
- 0, 0, // the points
- ff(150), 0,
- ff(80), ff(100),
- ff(150), ff(200),
- 0, ff(200),
- ff(80), ff(100)};
-
- long figureEightGeometricData[] = { 1, // number of contours
- 6, // number of points
- 0xff000000,
- 0, 0, // the points
- ff(150), 0,
- ff(75), ff(90),
- 0, ff(200),
- ff(150), ff(200),
- ff(75), ff(90)};
-
- long tripleEightGeometricData[] = { 1, // number of contours
- 6, // number of points
- 0xff000000,
- 0, 0, // the points
- ff(150), 0,
- ff(10), ff(100),
- ff(150), ff(200),
- 0, ff(200),
- ff(150), ff(100)};
- short loop,
- newHLoc,
- newPenWidth;
-
- InitCommonColors();
-
- //
- // Create the "gthePage" shape. We set the unique items attribute to make sure that each item added to the
- // picture has a unique reference. If this attribute was not set, we would not see all of the inset, outset, and on
- // geometry paths we create below.
- //
- gThePage = GXNewShape(gxPictureType);
- GXSetShapeAttributes(gThePage, gxUniqueItemsShape);
-
- //
- // Create a gxPath which has: starting with a pen thickness of 0, it's gxColor is green, and it's drawn with it's frame.
- // We will then draw the gxPath 6 times with an increasing (from 2 through 14) pen width
- //
- newHLoc = 10;
- newPenWidth = 3;
-
- thePath = GXNewPaths((gxPaths *) tripleDumpGeometricData);
- GXSetShapeFill (thePath, gxClosedFrameFill);
- SetShapeCommonColor (thePath, blue);
-
- for (loop = 0; loop < 8; loop ++)
- {
- GXMoveShapeTo (thePath, ff(newHLoc), ff(15));
- AddToShape(gThePage, thePath);
-
- GXSetShapePen(thePath, ff(newPenWidth));
-
- newPenWidth += 2;
- newHLoc += 70;
- }
- GXDisposeShape(thePath);
-
- //
- // Create a gxPath which looks like an oval with the middle sides pushed in. We will then draw it with the the gxStyle set to:
- // gxCenterFrameStyle, gxOutsideFrameStyle, and gxInsideFrameStyle.
- //
- thePath = GXNewPaths((gxPaths *) ovalWabbleGeometricData);
- GXSetShapeFill (thePath, gxClosedFrameFill);
- GXSetShapeStyleAttributes(thePath, gxOutsideFrameStyle);
- GXSetShapePen(thePath, ff(6));
- SetShapeCommonColor (thePath, red);
-
- GXMoveShapeTo (thePath, ff(10), ff(160));
-
- for (loop = 0; loop < 3; loop ++)
- {
- if (loop == 1) {
- GXSetShapeStyleAttributes(thePath, gxInsideFrameStyle);
- SetShapeCommonColor (thePath, green);
- }
-
- if (loop == 2) {
- GXSetShapePen(thePath, ff(3));
- GXSetShapeStyleAttributes(thePath, gxCenterFrameStyle);
- SetShapeCommonColor (thePath, blue);
- }
-
- AddToShape(gThePage, thePath);
- }
- GXDisposeShape(thePath);
-
- //
- // Create a gxPath which looks like a figure eight. We will then draw it with the the style set to:
- // gxCenterFrameStyle, gxOutsideFrameStyle, and gxInsideFrameStyle.
- //
- thePath = GXNewPaths((gxPaths *) figureEightGeometricData);
- GXSetShapeFill (thePath, gxClosedFrameFill);
- GXSetShapeStyleAttributes(thePath, gxOutsideFrameStyle);
- GXSetShapePen(thePath, ff(6));
- SetShapeCommonColor (thePath, red);
-
- GXMoveShapeTo (thePath, ff(155), ff(160));
-
- for (loop = 0; loop < 3; loop ++)
- {
- if (loop == 1) {
- GXSetShapeStyleAttributes(thePath, gxInsideFrameStyle);
- SetShapeCommonColor (thePath, green);
- }
-
- if (loop == 2) {
- GXSetShapePen(thePath, ff(3));
- GXSetShapeStyleAttributes(thePath, gxCenterFrameStyle);
- SetShapeCommonColor (thePath, blue);
- }
-
- AddToShape(gThePage, thePath);
- }
- GXDisposeShape(thePath);
-
- //
- // Create a gxPath which looks like a figure eight with a 3rd loop. We will then draw it with the the style set to:
- // gxCenterFrameStyle, gxOutsideFrameStyle, and gxInsideFrameStyle.
- //
- thePath = GXNewPaths((gxPaths *) tripleEightGeometricData);
- GXSetShapeFill (thePath, gxClosedFrameFill);
- GXSetShapeStyleAttributes(thePath, gxOutsideFrameStyle);
- GXSetShapePen(thePath, ff(6));
- SetShapeCommonColor (thePath, red);
-
- GXMoveShapeTo (thePath, ff(300), ff(160));
-
- for (loop = 0; loop < 3; loop ++)
- {
- if (loop == 1) {
- GXSetShapeStyleAttributes(thePath, gxInsideFrameStyle);
- SetShapeCommonColor (thePath, green);
- }
-
- if (loop == 2) {
- GXSetShapePen(thePath, ff(3));
- GXSetShapeStyleAttributes(thePath, gxCenterFrameStyle);
- SetShapeCommonColor (thePath, blue);
- }
-
- AddToShape(gThePage, thePath);
- }
- GXDisposeShape(thePath);
- }
-
-
-
- /*------ DoClick ---------------------------------------------------------------------------------------*/
-
- void DoClick( orgMouseLoc, theWindow )
- gxPoint orgMouseLoc;
- WindowPtr theWindow;
- {
- }
-
-
-
- /*------ DoDraw ---------------------------------------------------------------------------------------*/
- //
- // Draw the contents of "gthePage".
- //
- void DoDraw(gWindow)
- WindowPtr gWindow;
- {
- GXDrawShape (gThePage);
- }
-
-
- /*------ DoDispose -------------------------------------------------------------------------------------*/
-
- void DoDispose(gWindow)
- WindowPtr gWindow;
- {
- /**
- You should always dispose of your GX graphics objects before tossing your window. Why? It's generally good
- form and this approach guarantees that everything is disposed. If you had not disposed of everything, the
- call to DisposeWindow should dispose of the objects. If you are running the debugging version of the
- SecretGraphics init with notices set, you will receive a notice that you had not disposed of everything. You
- can turn notices on in this file by setting gDebugging = TRUE (above).
- **/
- GXDisposeShape(gThePage);
- GXDisposeShape(gWindowBoundsShape);
- DisposeCommonColors();
- DisposeWindow(gWindow);
- }
-
-
-
-
- /*------ DoIdle ----------------------------------------------------------------------------------------*/
-
- void DoIdle(gWindow)
- WindowPtr gWindow;
- {
- }
-